<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/jsp/common/tagPage.jsp" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8"/>
    <title>订单表</title>
    <meta name="keywords" content="中文"/>
    <meta name="description" content="下载"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>

    <!-- basic styles -->
    <link href="${baseurl}statics/assets/css/bootstrap.min.css" rel="stylesheet"/>
    <link rel="stylesheet" href="${baseurl}statics/assets/css/font-awesome.min.css"/>

    <!--[if IE 7]>
    <link rel="stylesheet" href="${baseurl}statics/assets/css/font-awesome-ie7.min.css"/>
    <![endif]-->
    <!-- fonts -->

    <link rel="stylesheet" href="${baseurl}statics/assets/css/fonts.css"/>
    <link rel="stylesheet" href="${baseurl}statics/assets/css/translateelement.css"/>

    <!-- ace styles -->

    <link rel="stylesheet" href="${baseurl}statics/assets/css/ace.min.css"/>
    <link rel="stylesheet" href="${baseurl}statics/assets/css/ace-rtl.min.css"/>
    <link rel="stylesheet" href="${baseurl}statics/assets/css/ace-skins.min.css"/>

    <!--[if lte IE 8]>
    <link rel="stylesheet" href="${baseurl}statics/assets/css/ace-ie.min.css"/>
    <![endif]-->

    <!-- inline styles related to this page -->
    <!-- 公共的js -->
    <script src="${baseurl}statics/assets/js/common.js"></script>
    <!-- ace settings handler -->

    <script src="${baseurl}statics/assets/js/ace-extra.min.js"></script>

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->

    <script type="text/javascript" src="${baseurl}statics/assets/js/jquery-1.10.2.min.js"></script>

    <!--[if lt IE 9]>
    <script src="${baseurl}statics/assets/js/html5shiv.js"></script>
    <script src="${baseurl}statics/assets/js/respond.min.js"></script>
    <![endif]-->

    <script type="text/javascript">
        $(function() {
            $.ajax({
                url: "${baseurl}order/selectKey",
                type: "post",
                dataType:"json",
                success: function (json) {
                    if(json.orderKey==1){
                        $("#checkAll").hide();
                        $("#noCheckAll").show();
                    }else{
                        $("#noCheckAll").hide();
                        $("#checkAll").show();
                    }
                },
                error: function (json) {
                    alert("error");
                }
            });
        });
    </script>

</head>

<body>

<div class="breadcrumbs" id="breadcrumbs">
    <script type="text/javascript">
        try {
            ace.settings.check('breadcrumbs', 'fixed')
        } catch (e) {
        }
    </script>

    <ul class="breadcrumb">
        <li>
            <i class="icon-home home-icon"></i>
            <a href="#">订单管理</a>
        </li>
        <li>
            <a href="${baseurl}order/findAllOrder?roleId=1&adminId=1">订单列表</a>
        </li>
        <li class="active">订单详情</li>
    </ul><!-- .breadcrumb -->
</div>

<div class="page-content">
    <div class="row">
        <div class="col-xs-12">
            <div class="row">
                <div class="col-xs-12">
                    <h3 class="header smaller lighter blue">订单数据列表</h3>
                    <div class="table-header">
                        订单数据列表信息
                    </div>
                    <div class="table-responsive">

                        <div style="width: 25%"   class="system_top_l clearfix">
                            <form class="form-search" action="${baseurl}order/findAllOrder?roleId=${sysUserManage.roleId}&adminId=${sysUserManage.id}"
                                  method="post">
                                <div class="row" style="margin-top: 20px;float: left;">
                                    <div class="col-xs-12 col-sm-8">
                                        <div class="input-group">
                                            <input type="text" class="form-control search-query" name="keywords" value="${keywords}"
                                                   placeholder="请输入订单号"/>
                                            <span class="input-group-btn">
                                                <button type="submit" class="btn btn-purple btn-sm">
                                                    搜索
                                                    <i class="icon-search icon-on-right bigger-110"></i>
                                                </button>
                                            </span>
                                        </div>
                                    </div>
                                </div>
                            </form>
                        </div>
                        <!-- 时间筛选 -->
                        <div style="float: left;"   class="system_top_r clearfix">
                            <shiro:hasPermission name="order:add">
                                <div style="margin-top: 20px;">
                                    <div id="inPermission">
                                        <a class="btn btn-purple btn-sm" href="${baseurl}order/toInsert"
                                        >添加</a>
                                    </div>
                                </div>

                            </shiro:hasPermission>



                        <%--</div>--%>
                        <%--<!--一键审核按钮-->--%>
                        <%--<div  class="open1">--%>
                            <%--<input type="button" id="checkAll" value="一键审核"/>--%>
                        <%--</div>--%>

                        <%--<!--取消一键审核按钮-->--%>
                        <%--<div class="open1">--%>
                            <%--<input type="button" id="noCheckAll" value="取消一键审核" style="display: none"/>--%>
                        <%--</div>--%>
                        <%--<div class="col-lg-12" style="margin-top: 10px">--%>
                        <shiro:hasPermission name="order:checked">
                            <div style="float: left;margin-top: 20px;">
                                <!--一键审核按钮-->
                                <div  class="open1">
                                    <input type="button" id="checkAll" value="一键审核" style="background-color: #9585bf !important;color: #fff;height: 36px;border: none;"/>
                                </div>

                                <!--取消一键审核按钮-->
                                <div class="open1">
                                    <input type="button" id="noCheckAll" value="取消一键审核" style="background-color: #9585bf !important;color: #fff;height: 36px;border: none;"/>
                                </div>
                            </div>
                        </shiro:hasPermission>
                        </div>
                    </div>
                        <%--<div class="col-lg-12" style="margin-top: 10px">--%>
                            <%--<form id="upLoad_form" method="post" action="${baseurl}fileController/upload" enctype="multipart/form-data">--%>
                                <%--<input type="file" id="picture" name="file" style="display: none">--%>
                                <%--<label   id="upload_btn" class="btn btn-primary" for="picture" >上传图片</label>--%>
                            <%--</form>--%>
                        <%--</div>--%>

                        <div class="col-lg-12" style="padding: 0">


                       <%-- <div class="col-lg-12" style="margin-top: 10px">

                            <form id="upLoad_form" method="post" action="${baseurl}fileController/upload" enctype="multipart/form-data">
                                <input type="file" id="picture" name="file">
                                <input  type="button"  class="btn btn-primary" onclick="uploadImg()" value="上传图片">
                            </form>
                        </div>--%>

                        <input type="hidden" id="adminName" value="${sysUserManage.userName}">
<%--                        <!--导入 -->
                        <div style="float: left;margin-top: 20px;">
                            <div id="">
                                <input type="button" class="btn btn-purple btn-sm" style="float: left;position: relative;bottom: 0px;left: 20px;" id="e2" value="导入" onclick="xuanze.click()"/>
                                <input type="file" id="xuanze" name="upfile"  style="float: left;display: none;">
                            </div>
                        </div>
                        <!--导出 -->
                        <div style="float: left;margin-top: 20px;">
                            <div >
                                <input type="button" class="btn btn-purple btn-sm" style="float: left;position: relative;bottom: 0px;left: 20px;" id="e3" value="导出"
                                       onclick="window.location.href='${baseurl}fileController/outExcel'"/>
                            </div>
                        </div>--%>

                        <%--<div id="">
                            <input type="button" class="btn btn-purple btn-sm" style="float: left;position: relative;bottom: -16px;" id="e2" value="导入" onclick="xuanze.click()"/>
                            <input type="file" id="xuanze" name="upfile"  style="float: left;display: none;">
                            <input type="button" class="btn btn-purple btn-sm" style="float: left;position: relative;bottom: -16px;" id="e3" value="导出"
                                   onclick="window.location.href='${baseurl}fileController/outExcel'"/>
                        </div>--%>

                        <table id="sample-table-2" class="table table-striped table-bordered table-hover"
                               style="text-align: center;vertical-align: middle">
                            <thead>
                            <tr>
                                <th class="center">
                                    <label>
                                        <input type="checkbox" class="ace"/>
                                        <span class="lbl"></span>
                                    </label>
                                </th>
                                <th style="text-align: center">订单号</th>
                                <th style="text-align: center">产生时间</th>
                                <th style="text-align: center">订单类型</th>
                                <th style="text-align: center">样品信息</th>
                                <th style="text-align: center">姓名</th>
                                <th style="text-align: center">合同价(元)</th>
                                <th style="text-align: center">业务状态</th>
                                <th style="text-align: center">审核状态</th>
                                <th style="text-align: center">业务状态</th>
                                <th style="text-align: center">
                                    业务操作
                                </th>
                            </tr>
                            </thead>
                            <tbody>
                            <c:forEach items="${page.records}" var="order">
                                <tr>
                                    <td class="center">
                                        <label>
                                            <input type="checkbox" class="ace"/>
                                            <span class="lbl"></span>
                                        </label>
                                    </td>
                                    <td style="text-align: center">${order.orderNo}</td>
                                    <td style="text-align: center">${fn:substring(order.applyTime,0,19)}</td>
                                    <td style="text-align: center">中底</td>
                                    <td style="text-align: center">样品：${order.model} 单价：${order.unitPrice}元/双 <c:if test="${order.sizeType==1}">标准码</c:if><c:if test="${order.sizeType==2}">欧码</c:if><c:if test="${order.sizeType==3}">美码</c:if></td>
                                    <td style="text-align: center">
                                            ${order.userName}(${order.userPhone})
                                    </td>
                                    <td style="text-align: center">
                                            ${order.contractPrice}
                                    </td>
                                    <td>
                                        <c:if test="${order.businessStatus == 1}">服务对接中
                                            <c:if test="${order.status == 2}">
                                                <a href="javascript:onclick = finish('${order.orderId}');"><span
                                                        style="color: red;font-weight: bold;">完成对接</span></a>
                                            </c:if>
                                        </c:if>
                                        <c:if test="${order.businessStatus == 2}">对接完成</c:if>
                                        <c:if test="${order.businessStatus == 3}">合同确认</c:if>
                                    </td>
                                    <td style="text-align: center">
                                        <c:if test="${count==0}">
                                            <c:if test="${order.status == 1}">审核中</c:if>
                                            <c:if test="${order.status == 2}"><span
                                                    style="color: green;font-weight: bold">审核通过</span></c:if>
                                            <c:if test="${order.status == 3}"><span
                                                    style="color: red;font-weight: bold">审核不通过</span>(请修改)</c:if>
                                        </c:if>
                                        <c:if test="${count==1}">
                                            <c:if test="${order.status == 2}"> <span
                                                    style="color: green;font-weight: bold">审核通过</span> </c:if>
                                            <c:if test="${order.status == 1}">审核中
                                                <a href="javascript:onclick = examine('${order.orderId}',2);">通过</a>
                                                <a href="javascript:onclick = examine('${order.orderId}',3);">不通过</a>
                                            </c:if>
                                            <c:if test="${order.status == 3}"><span
                                                    style="color: red;font-weight: bold">审核不通过</span>
                                            </c:if>
                                        </c:if>
                                    </td>
                                    <td style="text-align: center">
                                        <c:if test="${order.valid == 0}">
                                            禁用
                                        </c:if>
                                        <c:if test="${order.valid == 1}">
                                            启用
                                        </c:if>
                                        <c:if test="${order.valid == 2}">
                                            启用
                                        </c:if>
                                    </td>
                                    <td style="text-align: center">
                                        <div class="visible-md visible-lg hidden-sm hidden-xs action-buttons">
                                            <shiro:hasPermission name="order:find">
                                                <a class="blue" href="${baseurl}order/findById?orderId=${order.orderId}"
                                                   target="iframe_bt">
                                                    详情
                                                </a>
                                            </shiro:hasPermission>
                                            <!--审核不通过的情况下要进行修改-->
                                            <shiro:hasPermission name="order:update">
                                                <c:if test="${order.status == 3 && order.valid != 0}">
                                                    <a class="green" href="${baseurl}order/toUpdate?orderId=${order.orderId}">
                                                        修改
                                                    </a>
                                                </c:if>
                                            </shiro:hasPermission>
                                            <shiro:hasPermission name="order:isenable">
                                                <c:if test="${order.valid == 1 && order.status == 2}" >
                                                    <a href="javascript:onclick = isenable('${order.orderId}',0);"><span
                                                            style="color: red;font-weight: bold;">禁用</span></a>
                                                </c:if>
                                                <c:if test="${order.valid == 0 && order.status != 1}">
                                                    <a href="javascript:onclick = isenable('${order.orderId}',1);"><span
                                                            style="color: green;font-weight: bold;">启用</span></a>
                                                </c:if>
                                            </shiro:hasPermission>
                                        </div>
                                    </td>
                                </tr>
                            </c:forEach>
                            </tbody>
                        </table>
                        <jsp:include page="/WEB-INF/jsp/common/pageHelper.jsp"/>
                    </div>
                </div>
            </div>
        </div><!-- /.col -->
    </div><!-- /.row -->
    </div>


    <%--<div id="loadgif" style="width:66px;height:66px;position:absolute;top:50%;left:50%;">--%>
        <%--　　<img alt="加载中..." src="${baseurl}statics/assets/images/loading.png" width="80px" height="80px"/>--%>
    <%--</div>--%>

</div><!-- /.page-content -->

<script type="text/javascript">
    window.jQuery || document.write("<script src='${baseurl}statics/assets/js/jquery-2.0.3.min.js'>" + "<" + "/script>");
</script>

<!-- <![endif]-->

<!--[if IE]>
<script type="text/javascript">
    window.jQuery || document.write("<script src='${baseurl}statics/assets/js/jquery-1.10.2.min.js'>" + "<" + "/script>");
</script>
<![endif]-->

<script type="text/javascript">
    if ("ontouchend" in document) document.write("<script src='${baseurl}statics/assets/js/jquery.mobile.custom.min.js'>" + "<" + "/script>");
</script>
<script src="${baseurl}statics/assets/js/bootstrap.min.js"></script>
<script src="${baseurl}statics/assets/js/typeahead-bs2.min.js"></script>


<script src="${baseurl}statics/assets/js/ace-elements.min.js"></script>
<script src="${baseurl}statics/assets/js/ace.min.js"></script>

<!-- inline scripts related to this page -->

<script type="text/javascript">

    $('#checkAll').click(function(){
        var r=confirm("确定要一键审核吗?")
        if (r==true){
            $("#checkAll").hide();
            $("#noCheckAll").show();
            $.ajax({
                url: "${baseurl}order/keyPass",
                type: "post",
                dataType:"json",
                success: function (json) {
                    location.reload();
                },
                error: function (json) {
                    alert("error");
                }
            });
        }
    });

    $("#noCheckAll").click(function () {
        var r=confirm("确定要取消一键审核吗?")
        if (r==true){
            $("#noCheckAll").hide();
            $("#checkAll").show();
            $.ajax({
                url: "${baseurl}order/noKeyPass",
                type: "post",
                dataType:"json",
                success: function (json) {

                },
                error: function (json) {
                    alert("error");
                }
            });
        }
    });


//    删除用户数据
    function del(orderId) {
        var k = window.confirm("确定是否要删除！");
        if (k) {
            $.ajax({
                url: "${baseurl}order/delete",
                data: {"orderId": orderId},
                type: "post",
                success: function (json) {
                    console.log(json.code);
                    if (json.code == 0) {
                        alert(json.message);
                        location.reload();
                    } else {
                        alert(json.message);
                    }
                },
                error: function (json) {
                    alert("error");
                }
            });
        }
    }

    <!--启用或禁用-->
    function isenable(id, status) {
        var adminName = $("#adminName").val();
        var k = false;
        if (status === 0) {
            k = window.confirm("确定是否要禁用");
        } else {
            k = window.confirm("确定是否要启用");
        }
        if (k) {
            $.ajax({
                url: "${baseurl}order/isenable",
                data: {"orderId": id, "isenable": status, "adminName": adminName},
                type: "post",
                success: function (json) {
                    if (json.code === 0) {
                        alert(json.message);
                        location.reload();
                    } else {
                        alert(json.message);
                    }
                },
                error: function (json) {
                    alert("error");
                }
            });
        }
    }

    <!--审核通过或不通过-->
    function examine(id, status) {
        var adminName = $("#adminName").val();
        var k = false;
        if (status == 2) {
            k = window.confirm("确定是否要通过");
        } else {
            k = window.confirm("确定不通过吗?");
        }
        if (k) {
            $.ajax({
                url: "${baseurl}order/examine",
                data: {"orderId": id, "examine": status, "adminName": adminName},
                type: "post",
                success: function (json) {
                    console.log(json.code);
                    if (json.code == 0) {
                        alert(json.message);
                        location.reload();
                    } else {
                        alert(json.message);
                    }
                },
                error: function (json) {
                    alert("error");
                }
            });
        }
    }

    <!--点击确认完成对接-->
    function finish(id) {
        var k = false;
        k = window.confirm("确定是否要通过");
        if (k) {
            $.ajax({
                url: "${baseurl}order/finishDock",
                data: {"orderId": id},
                type: "post",
                success: function (json) {
                    console.log(json.code);
                    if (json.code == 0) {
                        alert(json.message);
                        location.reload();
                    } else {
                        alert(json.message);
                    }
                },
                error: function (json) {
                    alert("error");
                }
            });
        }
    }

    jQuery(function ($) {
//        var oTable1 = $('#sample-table-2').dataTable({
//            "aoColumns": [
//                {"bSortable": false},
//                null, null, null, null, null,
//                {"bSortable": false}
//            ]
//        });


        $('table th input:checkbox').on('click', function () {
            var that = this;
            $(this).closest('table').find('tr > td:first-child input:checkbox')
                .each(function () {
                    this.checked = that.checked;
                    $(this).closest('tr').toggleClass('selected');
                });

        });


        $('[data-rel="tooltip"]').tooltip({placement: tooltip_placement});
        function tooltip_placement(context, source) {
            var $source = $(source);
            var $parent = $source.closest('table')
            var off1 = $parent.offset();
            var w1 = $parent.width();
            var off2 = $source.offset();
            var w2 = $source.width();
            if (parseInt(off2.left) < parseInt(off1.left) + parseInt(w1 / 2)) return 'right';
            return 'left';
        }
    })
</script>
</body>
</html>

